package com.aijk.ehm.api;

import com.aijk.base.entity.PagingRequest;
import com.aijk.commons.exception.ErrorCodeException;
import com.aijk.ehm.model.BasHealthAssessment;
import com.aijk.ehm.model.qo.BasHealthAssessmentQo;
import com.aijk.ehm.service.BasHealthAssessmentService;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 健康评估结果表
 */
@Service("basHealthAssessmentApiImpl")
@Transactional
public class BasHealthAssessmentApiImpl implements BasHealthAssessmentApi {
    private static Logger logger = LoggerFactory.getLogger(BasHealthAssessmentApiImpl.class);

    @Autowired
    private BasHealthAssessmentService service;

    @Override
    public Long save(BasHealthAssessment bean) throws ErrorCodeException {
        service.save(bean);
        return bean.getId();
    }

    @Override
    public void update(BasHealthAssessment bean) throws ErrorCodeException {
        service.update(bean);
    }

    @Override
    public BasHealthAssessment findOne(Long id) throws ErrorCodeException {
        return service.findOne(id);
    }

    @Override
    public List<BasHealthAssessment> list(BasHealthAssessmentQo qo) {
        return service.find(qo);
    }

    @Override
    public void deleteById(Long id) throws ErrorCodeException {
        service.delete(id);
    }

    @Override
    public void delete(BasHealthAssessmentQo qo) throws ErrorCodeException {
        service.delete(qo);
    }

    @Override
    public int count(BasHealthAssessmentQo qo) {
        return service.count(qo);
    }

    @Override
    public PageInfo<BasHealthAssessment> page(BasHealthAssessmentQo qo) {
        PagingRequest pagingRequest = new PagingRequest(qo.getPageNo().intValue(), qo.getPageSize().intValue());
        return service.page(pagingRequest,qo);
    }
}